﻿using System;
using System.Linq;
using System.Web;
using System.Collections.Generic;
using Orchard;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Autoroute.Models;
using Orchard.Environment.Extensions;
using Morgma.Infographics.Models;
using Morgma.Infographics.ViewModels;


namespace Morgma.Infographics.Drivers {
    public class AutoroutePartDriver : ContentPartDriver<AutoroutePart> {
        private readonly IOrchardServices _orchardServices;

        public AutoroutePartDriver(IOrchardServices orchardServices) {
            _orchardServices = orchardServices;
        }

        protected override DriverResult Display(AutoroutePart part, string displayType, dynamic shapeHelper) {
            if (displayType == "SummaryAdmin") {
                var settings = _orchardServices.WorkContext.CurrentSite.As<GoogleInfographicsSettingsPart>();
                var viewModel = new QRCodeViewModel(part, settings);
                return ContentShape("Parts_Autoroute_SummaryAdmin", () =>
                    shapeHelper.Parts_Autoroute_SummaryAdmin(viewModel: viewModel));
            }
            else {
                return null;
            }
        }
    }
}